<template>
  <div class="dot-status">
    <div class="dot-status__dot">
      <div class="dot-status__dot__static"
        :class="bgColorClass"
        :style="{backgroundColor: customColor}"
      />

      <div class="dot-status__dot__animate"
        :class="{'animate-ping': animate, ...bgColorClass}"
        :style="{backgroundColor: customColor}"
      />
    </div>
    <div class="dot-status__text">{{ desc }}</div>
  </div>
</template>

<script>
import {defineComponent} from 'vue';

export default defineComponent({
  name: 'ArkDotStatus',
  props: {
    color: {
      type: String,
      default: 'gray',
      validator(value) {
        return ['red', 'orange', 'green', 'blue', 'gray'].includes(value);
      }
    },
    customColor: {
      type: String,
    },
    animate: {
      type: Boolean,
      default: false,
    },
    desc: {
      type: String,
    },
  },
  computed: {
    bgColorClass() {
      return {
        'bg-red': this.color === 'red',
        'bg-orange': this.color === 'orange',
        'bg-green': this.color === 'green',
        'bg-blue': this.color === 'blue',
        'bg-gray': this.color === 'gray',
      };
    }
  }
});
</script>

<style scoped>
.dot-status {
  @apply text-base flex items-center gap-x-1.5;

  .dot-status__dot {
    @apply relative flex items-center;

    .dot-status__dot__static {
      @apply h-1.5 w-1.5 rounded-full;
    }

    .dot-status__dot__animate {
      @apply h-1.5 w-1.5 rounded-full absolute;
    }
  }
}
</style>
